package com.huabo.system.oracle.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.system.oracle.entity.TblJob;
import com.huabo.system.oracle.entity.TblRole;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.BaseMapper;

import java.math.BigDecimal;
import java.util.List;

public interface TblJobDao extends BaseMapper<TblJob> {
    @Select("select * from TBL_JOB where COMPANYID= #{companyid}")
    List<TblJob> listBySql(BigDecimal companyid);

//    @Insert("INSERT INTO TBL_JOB (JOBID,JOBNAME,COMPANYID) VALUES (#{jobid},#{jobname},#{companyId})")
    @InsertProvider(method = "saveJob",type = TblJobDaoSqlConfig.class)
    void saveJob(TblJob job);

    @Select("SELECT * FROM TBL_JOB WHERE JOBID = #{jid}")
    TblJob selectJid(String jid);

    @Delete("DELETE FROM TBL_JOB WHERE selectedId = #{selectedId}")
    void deleteSelectedId(TblJob selectedId);

//    @Select("select * from TBL_JOB where COMPANYID=#{companyid}")
    @SelectProvider(method = "selectListByPageInfo",type = TblJobDaoSqlConfig.class)
    List<TblJob> selectListByPageInfo(PageInfo<TblJob> pageInfo, BigDecimal companyId);

    @Select("SELECT * FROM TBL_JOB where COMPANYID= #{companyId}")
    Integer selectListByPageInfoCount(PageInfo<TblJob> pageInfo, BigDecimal companyId);

    @Select("SELECT * FROM TBL_JOB WHERE JOBID = #{jobid}")
    List<TblJob> findByRid(String jobid);

    @UpdateProvider(type=TblJobDaoSqlConfig.class,method="updateJob")
    void updateJob(TblJob newJob);

    @Select("SELECT count(*) FROM TBL_JOB where COMPANYID= #{companyId}")
    Integer selectListByPageCount(PageInfo<TblJob> pageInfo, BigDecimal companyId);

    @Delete("DELETE FROM TBL_JOB WHERE JOBID = #{jobid}")
    void deleteJob(BigDecimal jobid);
    
    @Select("SELECT * FROM TBL_JOB WHERE historycode = #{historycode}")
    List<TblJob> findbyHistoryId(String historycode);
    
     @Update("update tbl_job j set j.categoryid=(select b.jobid from tbl_job b where b.historycode=j.categoryid) where datasource='zz'")
     void updateZzCategoryid();
    
}
